package com.example.treasure_back.service;

import com.example.treasure_back.mapper.DailySentenceMapper;
import com.example.treasure_back.model.DailySentenceModel;
import com.example.treasure_back.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;

@Service
public class DailySentenceService {

    @Autowired
    private DailySentenceMapper dailySentenceMapper;

    public DailySentenceModel getDailySentence(){
        Date date = new Date();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        String dateStr = format.format(date);
        Integer integer = DateUtils.dateToWeek(dateStr);
        return dailySentenceMapper.selectById(integer);
    }
}
